﻿using System.Reflection;
using NLite.Internal;
using System;
using NLite.Collections;

namespace NLite.Reflection
{
	



	/// <summary>
	/// 
	/// </summary>
	public static class GetterExtensions
	{
        private static readonly IMap<MemberInfo, Getter> getterCache = new Map<MemberInfo, Getter>();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="member"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static object Get(this MemberInfo member, object target)
        {
            return getterCache.GetOrAdd(member, () => member.GetGetter())(target);
        }
	}
}
